// manager.h

#ifndef MANAGER_H
#define MANAGER_H

#include "cashregister.h"
#include "clerk.h"
#include "locks.h"
//#include "customer.h"
//#include "stockboy"

/* The Manager has 3 jobs: 
 * (1) keep track of the total sales for the grocery store,
 * (2) keep track of the length of Customer lines, and 
 * (3) wake up StockBoys for either restocking shelves or helping Customers. 
 *
 * The Manager never goes on break. He just keeps checking to see if there is something to do. 
 * - Every so often the Manager will display the total sales of the entire store up to that point. 
 * - Whenever the Manager gets a call from a Clerk, they are to send a Clerk who is on break to an available Cash Register. 
 * - The Manager also wakes up StockBoys when the service button has been pushed by a Customer.
 * - The manager will regularly empty the CashRegister drawers to keep track of total sales.
 *  
 * There is only one Manager. 
 */

//These are temporary until the class errors are fixed. Cant compile
class Customer;
class Stockboy;

class Manager {
    private:
        Locks * _theLocks; //Will store all locks
    public:
        void IncreaseSales(double newVal)
        {
        	(_theLocks->totalStoreSales) += newVal;
        }
        void SetTotalSales(double newVal)
        {
        	_theLocks->totalStoreSales = newVal;
        }
        double GetTotalSales()
		{
			return _theLocks->totalStoreSales;
		}
	Manager(); //Default constructor
	//Manager constructor with the locks pointer passed
	Manager(Locks* _theLocks);

	//Manager function to be passed as a thread
	//Does all the work
	void DoWork();

	//Displays the total sales of the store
	void displayTotalSales();
	//Empties a given cash register
	void emptyRegister(CashRegister * cashRegister);
	//Is called when the line is long to wake up a clerk
        void clerkNeedsAssistance(Clerk * clerk, CashRegister * cashRegisters[]);
	//Wakes up a stock boy when service button pressed
	void customerNeedsAssistance(Stockboy * stockboys[], Customer * customer);
};

#endif /* MANAGER_H_ */
